package com.school.domain.vo;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;

import java.util.List;

@Data
public class PageVO<T> {
    private List<T> list;
    private Long totalCount;

    // 添加静态工厂方法
    public static <T> PageVO<T> of(List<T> list, long totalCount) {
        PageVO<T> pageVO = new PageVO<>();
        pageVO.setList(list);
        pageVO.setTotalCount(totalCount);
        return pageVO;
    }
    public PageVO() {
    }

    public PageVO(List<T> list, Long totalCount) {
        this.list = list;
        this.totalCount = totalCount;
    }
    public static <T> PageVO<T> MPPageToPageVO(Page<T> page) {
        return new PageVO<>(page.getRecords(), page.getTotal());
    }
    public static <T> PageVO<T> IPageToPageVO(IPage<T> page) {
        return new PageVO<>(page.getRecords(), page.getTotal());
    }
}
